package chendu.mapper;

import chendu.entity.PhoneInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PhoneInfoMapper extends BaseMapper<PhoneInfo> {
    @Select("select * from phone_info where category_type = #{categoryType}")
    List<PhoneInfo> findAllByCategoryType(@Param("categoryType") Integer categoryType);

    //根据phoneId查询对于的手机
    @Select("select * from phone_info where phone_id = #{phoneId}")
    PhoneInfo findById(@Param("phoneId") Integer phoneId);
    //修改库存
    @Update("update phone_info set phone_stock = #{phoneStock} where phone_id =#{phoneId}")
    void save(Integer phoneStock,Integer phoneId);
}
